/**
 * 对比生成随机整数的效率
 * 使用uniform_int_distribution(mt19937)的速度远快于random_device()()
 */

#include <iostream>
#include <random>
#include <chrono>

int main() {
    std::random_device rd;

    std::chrono::steady_clock::time_point t0 = std::chrono::steady_clock::now();
    for (int i = 0; i < 1000000; i++)
    {
        int x = rd() % 100;
    }
    std::chrono::steady_clock::time_point t1 = std::chrono::steady_clock::now();
    std::cout << "Time difference = " << std::chrono::duration_cast<std::chrono::milliseconds>(t1 - t0).count() << "[ms]" << std::endl;

    std::uniform_int_distribution<int> dist(0, 99);
    std::mt19937 rng(rd());
    t0 = std::chrono::steady_clock::now();
    for (int i = 0; i < 1000000; i++)
    {
        int x = dist(rng);
    }
    t1 = std::chrono::steady_clock::now();
    std::cout << "Time difference = " << std::chrono::duration_cast<std::chrono::milliseconds>(t1 - t0).count() << "[ms]" << std::endl;
    return 0;
}